<extend name="Common@Layout:hui-admin" />
<block name="title"><title>Administator管理后台</title></block>
<block name="style">
</block>

<block name="main">
	<nav class="breadcrumb">
		<i class="Hui-iconfont"></i>
		 首页 <span class="c-gray en">&gt;</span>
		 订单管理 <span class="c-gray en">&gt;</span>  
		 中途报名
		<a class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont"></i></a>
	</nav>
	
	<div class="pd-20">
		<div class="text-c"> 
			<form status="{:u('index')}" method="get" id="form">
			  <span class="select-box inline">
			<php>
				$searchtypes = array(
						'ddbh'=>'订单编号',
						'stuname'=>'学生姓名',
						'tel'=>'电话'
					);
			</php>
			<select name="searchtype" class="select">
				<foreach name="searchtypes" item="vo">
					<option value="{$key}" <eq name="_GET['searchtype']" value="$key">selected</eq>>{$vo}</option>
				</foreach>
			</select>
			</span> 日期范围：
			<input type="text" name="start_time" value="{$_GET['start_time']}" class="input-text mini-time" style="width:120px;">
			-
			<input type="text" name="end_time" value="{$_GET['end_time']}" class="input-text mini-time" style="width:120px;">
			<input type="text" name="keywords" value="{$_GET['keywords']}" id="" placeholder="标题关键词" style="width:250px" class="input-text">
			<button name="" id="" class="btn btn-success" type="submit"><i class="Hui-iconfont"></i> 搜索</button>
			</form>
		</div>
		<div class="cl pd-5 bg-1 bk-gray mt-20"> 
			<div class="btn-group l">
				<a href="{:U('midpay',array('status'=>1))}" class="btn btn-default <if condition='$_GET[status] eq 1'>btn-primary</if> radius">未处理</a>
				<a href="{:U('midpay',array('status'=>2))}" class="btn btn-default <if condition='$_GET[status] eq 2'>btn-primary</if> radius">已处理</a>
			</div>
			<if condition="$role eq 'ROLE_SUPER_ADMIN'">
			<span class="l ml-20"> 
				<a href="javascript:;" class="btn btn-danger radius ajax-post confirm" target-form="mini-form" data-msg="确定批量删除？" data-url="{:U('orderadmin/midpay_del')}"><i class="Hui-iconfont"></i> 批量删除</a> 
			</span> 
			</if>
		</div>
		<php>
			$serch = $_GET;
			if($serch['searchtype'] && $serch['keywords']){
				$mmap[$serch['searchtype']] = array('like','%'.$serch['keywords'].'%');
			}
			if($serch['start_time'] && $serch['end_time']){
				$mmap['update_time'] = array('between',array($serch['start_time'],$serch['end_time']));
			}
			if($mmap){
				$ids = M('YgclOrder')->where($mmap)->getField('id',true);
			}
			if($ids){
				$map['orderid'] = array('in',$ids);
			}else{
				$map['orderid'] = 0;
			}
			if(!$serch['keywords']){
				unset($map['orderid']);
			}
			$xiaoqu = R('Apiadmin/getxiaoqurole');
			if($xiaoqu){
				$map['did'] = array('in',$xiaoqu);
			}
			$result = _get_list_data('/Ygcl/Orderadmin/midpay/',$_GET,$map,D('YgclMidpay'));
		</php>
		<form class="mini-form">
		<table class="table table-border table-bordered table-bg table-hover table-sort">
			<thead>
				<tr>
					<th scope="col" colspan="10"><a class="btn btn-primary radius" href="{:U('export_midpay',$_GET)}">导出数据并生成excel</a> </th>
				</tr>
				<tr class="text-c">
					<th width="25"><input type="checkbox" name="" value=""></th>
					<th width="50">ID</th>
					<th width="140">订单编号</th>
					<th>用户</th>
					<th>电话</th>
					<th>类型</th>
					<th width="60">费用</th>
					<th width="200">微信订单号</th>
					<th width="60">状态</th>
					<th width="120">操作</th>
				</tr>
			</thead>
			<tbody>
				<php>$type = C('ORDER_TYPE');</php>
				<foreach name="result['data']['list']" item="vo">
				<tr class="text-c">
					<td><input type="checkbox" value="{$vo['id']}" name="ids[]"></td>
					<td>{$vo['id']}</td>
					<td>{$vo.orderinfo.ddbh}</td>
					<td>{$vo.orderinfo.stuname}</td>
					<td>{$vo.orderinfo.tel}</td>
					<td>{$type[$vo['orderinfo']['type']]}</td>
					<td>{$vo.orderinfo.total}</td>
					<td>{$vo.orderinfo.wxddh}</td>
					<td class="td-status">
						<if condition="$vo['status'] eq 2">
						<span class="label label-success radius">已处理</span>
						</if>
						<if condition="$vo['status'] eq 1">
						<span class="label label-default radius">未处理</span>
						</if>
					</td>
					<td class="f-14 td-manage">
						<a style="text-decoration:none" href="javascript:;" class="btn btn-primary radius qr_order" data-id="{$vo.id}"><if condition="$vo['status'] eq 1">确认<else/>取消</if></a> 
            			<a style="text-decoration:none" href="javascript:;" onclick="open_iframe_dialog('{:U('detail',array(id=>$vo['orderid']))}','订单详情',['600px','600px'],1)" title="订单详情"><i class="Hui-iconfont"></i></a> 
            			<a style="text-decoration:none;display:none;" class="ml-5 mini_del" data-url="{:U('orderadmin/midpay_del','ids='.$vo['id'])}" href="javascript:;" title="删除"><i class="Hui-iconfont"></i></a>
					</td>
				</tr>
				</foreach>
			</tbody>
		</table>
		</form>
		{$result['pagetpl']}
	</div>
	
	
</block>

<block name="script">
<script>
$(function(){
	$('.mini-time').datepicker();
});

$(".qr_order").click(function(){
	var id = $(this).attr("data-id");
	$.post('/ygcl/orderadmin/changemidpay',{id:id},function(data){
		if(data.status){
			layer.msg(data.info, {icon: 1,time:1000},function(){
			    location.reload();
			});
		}else{
			layer.msg(data.info, {icon: 2,time:1000});
		}
	})
})
</script>
</block>